package com.sinoglobal.sinostore.adapter;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.TextView;

import com.sinoglobal.sinostore.R;
import com.sinoglobal.sinostore.system.Constants;

/**
 * @Title: ScreenListAdapter.java
 * @Package com.sinoglobal.searchingforfood.fragment
 * @Description: TODO(用一句话描述该文件做什么)
 * @author czz
 * @date 2014-5-13 下午1:58:29
 */
public class ScreenListAdapter extends BaseAdapter implements ListAdapter {
	private Context context;
	public int num = 0;
	private List<String> areaListVo;

	public ScreenListAdapter(Context context, int type , List<String> data) {
		this.context = context;
		if (type == 1) {
			num  = Constants.Type_POSITION;
		}else if(type == 2){
			num = Constants.SORT_POSITION;
		}
		this.areaListVo = data;
	}
	
	public void setAreaListVo(List<String> shopWareTypeList) {
		this.areaListVo = shopWareTypeList;
	}

	public void updateData(List<String> shopWareTypeList){
		this.areaListVo = null;
		this.areaListVo = shopWareTypeList;
		notifyDataSetChanged();
	}
	
	@Override
	public int getCount() {
		return areaListVo.size();
	}

	@Override
	public String getItem(int position) {
		return areaListVo.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(null == convertView){
			convertView = LayoutInflater.from(context).inflate(R.layout.shop_screenlist_item, null);
		}
		String shopWareTypeVo = areaListVo.get(position);
		TextView screnlist_tv = ViewHolder.getViewById(convertView, R.id.screnlist_tv);
		convertView.setBackgroundColor(Color.parseColor("#ffffff"));
		if (num == position) {
			convertView.setBackgroundColor(Color.parseColor("#EEEEEE"));
		}
		screnlist_tv.setText(shopWareTypeVo);
		return convertView;
	}
}
